﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LeeAnn.Framework;

namespace LeeAnn
{
    public class Vector2D
    {
        //TODO make x and y privates and have an boolChanged variable to tell if anything was changed, so we can save calculated values.
        public float X { get; set; }
        public float Y { get; set; }
        public float Angle
        {
            get
            {
                return Maths.RadianToDegree(rotRadians);
            }
            set
            {
                rotRadians = Maths.DegreeToRadian(value);
            }
        }
        public float Radians
        {
            get
            {
                return rotRadians;
            }
            set
            {
                rotRadians = value;
            }
        }
        public float Speed { get; set; }
        public float XVelocity { get; set; }
        public float YVelocity { get; set; }

        public static Vector2D operator - (Vector2D c1, Vector2D c2)
        {
            return new Vector2D(c1.X - c2.X,c1.Y-c2.Y);
        }
        private float rotRadians = 0f;
        public double Length()
        {
            //INFO Calculated value that needs to be saved
            return  Math.Sqrt(Math.Pow(X,2) + Math.Pow(Y,2));
        }
        public Vector2D(float x, float y)
        {
            X = x;
            Y = y;
            Speed = 0f;
            XVelocity = 0f;
            YVelocity = 0f;
        }
        public void MoveUp()
        {
            XVelocity = (float)Math.Sin(Radians);
            YVelocity = -(float)Math.Cos(Radians);
            X += XVelocity * Speed;
            Y += YVelocity * Speed;
        }
    }
}
